/*
 * Created by SharpDevelop.
 * User: K 3 N ! L
 * Date: 12/7/2008
 * Time: 5:50 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;

namespace ChallanSystem
{
	/// <summary>
	/// Description of ProductCategorySearch.
	/// </summary>
	public partial class ProductCategorySearch : Form
	{
		ProdCategorySearch ctgrySearch = null;
		DataSet dsCtgryDetails = null;
		
		public ProductCategorySearch()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			RefreshDataGrid();
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		public void RefreshDataGrid()
		{
			ctgrySearch = new ProdCategorySearch();
			dsCtgryDetails = ctgrySearch.View();
			datagridProductCategory.SetDataBinding(dsCtgryDetails, "Product_Category");
		}
		
		
		void CreateCategoryClick(object sender, EventArgs e)
		{
			bool validateFlag = validate();
			bool insertFlag = false;
			MessageBox.Show("Status : "+validateFlag.ToString());
			
			if(validateFlag)
			{
				insertFlag = ctgrySearch.insertCategory(txtCategoryName.Text);
				if(insertFlag)
					RefreshDataGrid();
			}
			else
			{
				MessageBox.Show("Please Provide Category Name");
			}
		}
		
		private bool validate()
		{
			if(txtCategoryName.Text == "")
				return false;
			else
				return true;
		}
	}
}
